package com.tanhua.dubbo.test;
import org.bson.types.ObjectId;

import com.tanhua.domain.mongo.TestSoulReportIdAndScore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class createReportIdAndScore {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Test
    public void testAddData() {
        Query query = new Query(Criteria.where("UserId").is("1"));
        TestSoulReportIdAndScore one = mongoTemplate.findOne(query, TestSoulReportIdAndScore.class);
        one.setUserId("5");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("7");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("8");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("9");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("13");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("26");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("27");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("28");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("29");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("31");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("32");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("33");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("34");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("35");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("36");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

        one.setUserId("37");
        one.setId(new ObjectId());
        mongoTemplate.insert(one);

    }

    @Test
    public void test() {
        TestSoulReportIdAndScore reportIdAndScore = new TestSoulReportIdAndScore();
//        reportIdAndScore.setId(new ObjectId());
        reportIdAndScore.setUserId("");
        reportIdAndScore.setReportId_1("");
        reportIdAndScore.setReportId_2("");
        reportIdAndScore.setReportId_3("");
        reportIdAndScore.setScore_1(0);
        reportIdAndScore.setScore_2(0);
        reportIdAndScore.setScore_3(0);
        reportIdAndScore.setIsLock_1(0);
        reportIdAndScore.setIsLock_2(1);
        reportIdAndScore.setIsLock_3(1);

        mongoTemplate.insert(reportIdAndScore);


    }
}
